﻿<!--类别选择树-->
@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <title>选择类别</title>
    @if (false)
    {
        <script src="../../../../Scripts/jquery-vsdoc.js" type="text/javascript"></script>  
        <script src="../../../../Scripts/ASPxScriptIntelliSense.js" type="text/javascript"></script>  
        <script src="../../../../Scripts/json2.js" type="text/javascript"></script>  
    }
    <link href="@Url.Content("~/Content/jquery-ui.css", true)" rel="stylesheet" type="text/css" />

    <script src="@Url.Content("~/Scripts/jquery.min.js", true)" type="text/javascript"></script>

    <script src="@Url.Content("~/Scripts/jquery-ui.min.js", true)" type="text/javascript"></script>

    <link href="@Url.Content("~/Scripts/dynatree/skin/ui.dynatree.css", true)" rel="stylesheet" type="text/css" />

    <script src="@Url.Content("~/Scripts/dynatree/jquery.dynatree.min.js", true)" type="text/javascript"></script>

    <script src="@Url.Content("~/Scripts/json2.js", true)" type="text/javascript"></script>

    <script src="@Url.Content("~/Common/GetRootPath.ashx", true)" type="text/javascript"></script>

    @Html.DevExpress().GetStyleSheets(

    new StyleSheet { ExtensionType = ExtensionType.ListBox, Theme = DevExpressHelper.Theme }
    )
    @Html.DevExpress().GetScripts(
        new Script { ExtensionType = ExtensionType.ListBox }
    )
    <style type="text/css">
        #tree ul.dynatree-container
        {
            overflow: auto;
            position: relative;
            height: 90%;
        }
        #treeDiv
        {
            overflow: auto;
            position: relative;
            height: 465px;
        }
        body
        {
            margin: 0px;
            font-size: 12px;
        }
    </style>

    <script type="text/javascript">
        var data = @Html.Raw(Json.Encode(ViewData["treeJsonStr"]));
        if (data!="")
            {
                data=JSON.parse(data);
            }
            else
            {
                data=null;
            }
        var selectMode=@ViewData["treeSelectMode"];
        var checkboxMode=@ViewData["checkboxMode"];
    </script>

    <script type="text/javascript">
        $(document).ready(function () {
            $("#tree").dynatree({
                checkbox: checkboxMode,
                selectMode: selectMode,
                clickFolderMode: 1,
                children: data,
                keyboard: false
            });

            $("#btnOK").bind("click", function () {

                var partsel = new Array();
                var check = $("#tree").dynatree("option", "checkbox");
                if (check == true) {

                    var selNodes = $("#tree").dynatree("getTree").getSelectedNodes(false);
                    $.map(selNodes, function (node) {
                        if (node.data.children == null) {
                            var treeModel = { "Text": "", "Value": "" };
                            treeModel.Text = node.data.title;
                            treeModel.Value = node.data.key;

                            while (node.parent.data.key != "-1") {
                                treeModel.Text = node.parent.data.title + "->" + treeModel.Text;
                                node = node.parent;
                            }
                            partsel.push(treeModel);
                        }
                    });
                }
                else {
                    var node = $("#tree").dynatree("getTree").getActiveNode();
                    var treeModel = { "Text": "", "Value": "" };
                    treeModel.Text = node.data.title;
                    treeModel.Value = node.data.key;
                    partsel.push(treeModel);
                }

                //开始转移
                if (partsel.length > 0) {
                    var docId = $("#hdDocId").val();
                    var targetClsNo = partsel[0].Value;
                    $.ajax({
                        type: 'POST',
                        url: rootPath + '/Admin/DocumentManage/TransferDocs',
                        data: { docId: docId, targetClsNo: targetClsNo },
                        success: function (jsonstr) {
                            var msg = jsonstr.split('|');
                            if (msg[0] == "SUCCESS") {
                                alert("数据转移成功");
                                window.returnValue = "SUCCESS";
                                window.close();
                            }
                            else {
                                if (msg.length > 1) {
                                    alert(msg[1]);
                                }
                            }
                        }
                    });
                }
                else {
                    alert("请选择一个信息类别");
                }
            });
            $("#btnCancel").bind("click", function () {
                window.close();
            });
            //            var obj = window.dialogArguments;
            //            docIds = obj.value;

        });

    </script>

</head>
<body>
    <div id="treeDiv">
        <div id="tree">
        </div>
    </div>
    <div style="padding: 0px; background: #efefef; width: 100%; font-size: 12px; text-align: center;">
        <table align="center">
            <tr>
                <td>
                    @Html.DevExpress().Button(settings =>
               {
                   settings.Name = "btnOK";
                   settings.Text = "确定";

                   settings.Images.Image.Url = Url.Content("~/Content/ControlImages/ok.png");

               }).GetHtml()
                </td>
                <td>
                    @Html.DevExpress().Button(settings =>
               {
                   settings.Name = "btnCancel";
                   settings.Text = "取消";

                   settings.Images.Image.Url = Url.Content("~/Content/ControlImages/no.png");
                   settings.CausesValidation = false;

               }).GetHtml()
                </td>
            </tr>
        </table>
        @Html.Hidden("hdDocId", ViewData["docId"]);
    </div>
</body>
</html>
